﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="QLThanhVien.aspx.cs" Inherits="admin_Default2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <style type="text/css">
        .lb {
            width: 30%;
            text-align: right;
            float: left;
        }

        .txt {
            width: 67%;
            margin-left: 2%;
        }

        .ddl {
            margin-left: 2%;
        }

        .btn {
            align-items: center;
            float: right;
        }

        div.row {
            margin: auto;
            padding: 2px;
            height: 26px;
            width: 407px;
        }

        div.head {
            height: 30px;
            background-color: #507CD1;
            font-size: 15pt;
        }

        div.center {
            position: fixed;
            height: 270px;
            width: 418px;
            top: 50%;
            margin-top: -135px;
            left: 49%;
            margin-left: -209px;
            background-color: #ffffff;
            border: 2px solid #507CD1;
            padding: 0px;
        }

        a.btnClose {
            float: right;
            text-decoration: none;
            color: black;
        }
        </style>
</head>
<body>
    <form id="form1" runat="server">
        <div>

            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <div style="margin: auto; width:1000px;">
                        <asp:TextBox ID="txtTim" runat="server"></asp:TextBox>
            <asp:Button ID="btnTim" runat="server" Text="Tìm kiếm" />
                        <asp:CheckBox ID="CheckBox2" runat="server" Text="Hiện thành viên bị xóa" Checked="True" OnCheckedChanged="CheckBox2_CheckedChanged" />
                        <asp:Button ID="btnThem" runat="server" OnClick="btnThem_Click" Text="Thêm TV" />
                    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" OnRowCommand="GridView1_RowCommand" CellPadding="4" ForeColor="#333333" GridLines="None" Width="1000px" >
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                        <Columns>
                            <asp:BoundField DataField="TENDN" HeaderText="Tên Đăng Nhập" SortExpression="TENDN" />
                            <asp:TemplateField HeaderText="Loại TV" SortExpression="TENLOAITV">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("TENLOAITV") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("TENLOAITV") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="HOTEN" HeaderText="Họ Tên" SortExpression="HOTEN" />
                            <asp:BoundField DataField="DIACHI" HeaderText="Địa Chỉ" SortExpression="DIACHI" />
                            <asp:BoundField DataField="SDT" HeaderText="SĐT" SortExpression="SDT" />
                            <asp:BoundField DataField="EMAIL" HeaderText="Email" SortExpression="EMAIL" />
                            <asp:TemplateField HeaderText="Xóa" SortExpression="XOA">
                                <EditItemTemplate>
                                    <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("XOA") %>' />
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("XOA") %>' />
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:TemplateField InsertVisible="False" ShowHeader="False">
                                <EditItemTemplate>
                                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Update"></asp:LinkButton>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandArgument='<%# Eval("TENDN") %>' CommandName="sua" Text="Sửa"></asp:LinkButton>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <EditRowStyle BackColor="#999999" />
                        <EmptyDataTemplate>
                            <asp:Label ID="Label2" runat="server" Text="Không tìm thấy thành viên nào"></asp:Label>
                        </EmptyDataTemplate>
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                        <SortedAscendingCellStyle BackColor="#E9E7E2" />
                        <SortedAscendingHeaderStyle BackColor="#506C8C" />
                        <SortedDescendingCellStyle BackColor="#FFFDF8" />
                        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                    </asp:GridView>
                    </div>
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                        SelectCommand="SELECT THANHVIEN.TENDN, LOAITV.TENLOAITV, THANHVIEN.HOTEN, THANHVIEN.DIACHI, THANHVIEN.SDT, THANHVIEN.EMAIL, THANHVIEN.XOA FROM (LOAITV INNER JOIN THANHVIEN ON LOAITV.MALOAI = THANHVIEN.LOAITV) WHERE (THANHVIEN.TENDN LIKE '%' + ? + '%') AND (THANHVIEN.XOA <> ?)">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="txtTim" DefaultValue="%" Name="Tendn" PropertyName="Text" />
                            <asp:ControlParameter ControlID="CheckBox2" DbType="Boolean" DefaultValue="TRUE" Name="Xoa" PropertyName="Checked" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT [MALOAI], [TENLOAITV] FROM [LOAITV] ORDER BY [MALOAI]">
                    </asp:SqlDataSource>
                    <asp:Panel ID="pnEdit" runat="server" CssClass="center" Visible="False">

                        <div class="head">
                            <label style="float: left">Sửa thông tin thành viên</label>&nbsp;
                        <asp:LinkButton ID="lbtnDong" runat="server" CssClass="btnClose" OnClick="lbtnDong_Click">Đóng</asp:LinkButton>
                        </div>
                        <div class="row">
                            <label class="lb">Tên đăng nhập:</label>
                            <asp:TextBox ID="txtTenDN" runat="server" CssClass="txt"></asp:TextBox>
                        </div>
                        <div class="row">
                            <label class="lb">Loại thành viên:</label>
                            <asp:DropDownList ID="ddlLoai" runat="server" DataSourceID="SqlDataSource2" DataTextField="TENLOAITV" DataValueField="MALOAI" CssClass="ddl">
                            </asp:DropDownList>
                        </div>
                        <div class="row">
                            <label class="lb">Mật khẩu mới:</label>
                            <asp:TextBox ID="txtMK" runat="server" CssClass="txt"></asp:TextBox>

                        </div>
                        <div class="row">
                            <label class="lb">Họ tên:</label>
                            <asp:TextBox ID="txtHoten" runat="server" CssClass="txt"></asp:TextBox>
                        </div>
                        <div class="row">
                            <label class="lb">Địa chỉ:</label>
                            <asp:TextBox ID="txtDiachi" runat="server" CssClass="txt"></asp:TextBox>
                        </div>
                        <div class="row">
                            <label class="lb">SĐT:</label>
                            <asp:TextBox ID="txtSdt" runat="server" CssClass="txt"></asp:TextBox>
                        </div>
                        <div class="row">
                            <label class="lb">Email:</label>
                            <asp:TextBox ID="txtEmail" runat="server" CssClass="txt"></asp:TextBox>
                            <div class="row">

                                <asp:Button ID="btnUpdate" runat="server" CssClass="btn" Text="Cập nhật" OnClick="btnCapnhat_Click" />
                                <asp:Button ID="Button2" runat="server" CssClass="btn" Text="Hủy bỏ" OnClick="Button2_Click" />
                            </div>
                        </div>

                    </asp:Panel>
                    <asp:Panel ID="Panel1" runat="server">
                    </asp:Panel>
                </ContentTemplate>
            </asp:UpdatePanel>
            <asp:UpdateProgress ID="UpdateProgress1" runat="server">
            </asp:UpdateProgress>

        </div>
    </form>
</body>
</html>
